<template>
  <el-dialog v-model="visible" :title="'详情'" :close-on-click-modal="false" :close-on-press-escape="false">
    <el-form :model="dataForm" :rules="rules" ref="dataFormRef" @keyup.enter="dataFormSubmitHandle()" label-width="120px" disabled="true">
      <el-form-item label="项目名称" prop="purchaseProjectName">
        <el-input v-model="dataForm.purchaseProjectName" placeholder=""></el-input>
      </el-form-item>
      <el-form-item label="项目编号" prop="purchaseProjectCode">
        <el-input v-model="dataForm.purchaseProjectCode" placeholder=""></el-input>
      </el-form-item>
      <el-form-item label="交易编号" prop="tradeCode">
        <el-input v-model="dataForm.tradeCode" placeholder=""></el-input>
      </el-form-item>
      <el-form-item prop="purchaseProjectType" label="项目类型">
        <ren-radio-group v-model="dataForm.purchaseProjectType" dict-type="purchase_project_type"></ren-radio-group>
      </el-form-item>
      <el-form-item prop="purchaseMode" label="采购方式">
        <ren-radio-group v-model="dataForm.purchaseMode" dict-type="purchase_mode"></ren-radio-group>
      </el-form-item>
      <el-form-item label="采购组织形式" prop="tenderOrganizeForm">
        <ren-radio-group v-model="dataForm.tenderOrganizeForm" dict-type="tender_organize_form"></ren-radio-group>
      </el-form-item>
      <el-form-item label="采购人共享平台" prop="purchaseShareId">
        <el-input v-model="dataForm.purchaseShareName" placeholder=""></el-input>
      </el-form-item>
<!--      <el-form-item label="采购人名称" prop="purchaseBodyName">-->
<!--        <el-input v-model="dataForm.purchaseBodyName" placeholder=""></el-input>-->
<!--      </el-form-item>-->
<!--      <el-form-item label="代理机构共享平台" prop="agencyShareId">-->
<!--        <ren-dept-tree v-model="dataForm.agencyShareId" placeholder="请选择" v-model:deptName="dataForm.deptName"></ren-dept-tree>-->
<!--      </el-form-item>-->
      <el-form-item label="代理机构共享平台" prop="agencyBodyName">
        <el-input v-model="dataForm.agencyBodyName" placeholder=""></el-input>
      </el-form-item>
      <el-form-item label="采购内容" prop="projectContent">
        <el-input type="textarea" :autosize="{ minRows: 2, maxRows: 6 }" v-model="dataForm.projectContent" placeholder=""></el-input>
      </el-form-item>
      <el-form-item label="项目资金来源" prop="fundSource">
        <el-input v-model="dataForm.fundSource" placeholder=""></el-input>
      </el-form-item>
      <el-form-item label="项目概算金额(元)" prop="estimatesMoney">
        <el-input v-model="dataForm.estimatesMoney" placeholder=""></el-input>
      </el-form-item>
      <el-form-item label="项目联系人" prop="linkMan">
        <el-input v-model="dataForm.linkMan" placeholder=""></el-input>
      </el-form-item>
      <el-form-item label="联系人手机号码" prop="linkMobile">
        <el-input v-model="dataForm.linkMobile" placeholder=""></el-input>
      </el-form-item>
      <el-form-item label="当前环节" prop="processStatus">
        <ren-radio-group v-model="dataForm.processStatus" dict-type="purchase_process_status"></ren-radio-group>
      </el-form-item>
      <!--          <el-form-item label="当前环节名称" prop="processName">-->
      <!--            <el-input v-model="dataForm.processName" placeholder="当前环节名称"></el-input>-->
      <!--          </el-form-item>-->
      <el-form-item label="创建人共享平台" prop="createBodyShareId">
        <el-input v-model="dataForm.createBodyShareName" placeholder=""></el-input>
      </el-form-item>
      <el-form-item label="公告是否发布" prop="isPublishAnnouncement">
        <ren-radio-group v-model="dataForm.isPublishAnnouncement" dict-type="is_or_no"></ren-radio-group>
      </el-form-item>
          <el-form-item label="项目创建人" prop="createUser">
        <el-input v-model="dataForm.createUser" placeholder=""></el-input>
      </el-form-item>
          <el-form-item label="项目创建时间" prop="createTime">
        <el-input v-model="dataForm.createTime" placeholder=""></el-input>
      </el-form-item>
          <el-form-item label="最后更新人" prop="updateUser">
        <el-input v-model="dataForm.updateUser" placeholder=""></el-input>
      </el-form-item>
          <el-form-item label="最后更新时间" prop="updateTime">
        <el-input v-model="dataForm.updateTime" placeholder=""></el-input>
      </el-form-item>
    </el-form>
  </el-dialog>
</template>

<script lang="ts" setup>
import { reactive, ref } from "vue";
import baseService from "@/service/baseService";
import { ElMessage } from "element-plus";
const emit = defineEmits(["refreshDataList"]);

const visible = ref(false);
const dataFormRef = ref();

const dataForm = reactive({
  purchaseProjectId: '',  purchaseProjectName: '',  purchaseProjectCode: '',  tradeCode: '',  purchaseProjectType: '',  purchaseMode: '',  tenderOrganizeForm: '',  purchaseShareId: '',  purchaseBodyName: '',  agencyShareId: '',  agencyBodyName: '',  projectContent: '',  fundSource: '',  estimatesMoney: '',  linkMan: '',  linkMobile: '',  processStatus: '',  processName: '',  createBodyShareId: '',  isPublishAnnouncement: '',  createUser: '',  createTime: '',  updateUser: '',  updateTime: ''});


const init = (purchaseProjectId?: number) => {
  visible.value = true;
  dataForm.purchaseProjectId = "";

  // 重置表单数据
  if (dataFormRef.value) {
    dataFormRef.value.resetFields();
  }

  if (purchaseProjectId) {
    getInfo(purchaseProjectId);
  }
};

// 获取信息
const getInfo = (purchaseProjectId: number) => {
  baseService.get("/purchaseproject/purchaseproject/" + purchaseProjectId).then((res) => {
    Object.assign(dataForm, res.data);
  });
};

defineExpose({
  init
});
</script>
